package cn.hinglo.website.controller;

import cn.hinglo.baseservice.base.BaseController;
import cn.hinglo.common.entity.Result;
import cn.hinglo.website.bean.model.Banner;
import cn.hinglo.website.service.BannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;


/**
 * @createTime: 2018/9/21 13:44
 * @author: HingLo
 * @description: banner相关处理
 */
@RestController
@RequestMapping("/banner")
@Validated
public class BannerController extends BaseController {

    @Autowired
    private BannerService bannerService;

    /**
     * 查询全部的Banner列表
     */
    @GetMapping("list")
    public Result list() {
        return success(bannerService.listService());
    }

    /***
     * 添加banner图
     *
     * @param banner banner图对象信息
     * @param img img
     */
    @PostMapping("add")
    public Result add(Banner banner, MultipartFile img) {
        System.out.println(banner);
        return result(bannerService.addService(banner, img));
    }
}
